﻿@model BackEndAdminPagesAdd
<div class="row">
    <div class="col-lg-12">
        @using (Html.BootstrapBeginForm())
        {
            <div class="panel panel-default">
                <div class="panel-heading">
                    @Html.BootstrapSubmit()
                    @Html.BootstrapResetForm()
                    @Html.BootstrapButtonRedirect("/Admin/AdminPages", MVCwCMS.Resources.Strings.AdminPages)
                </div>
                <div class="panel-body">

                    @Html.AntiForgeryToken()
                    @Html.BootstrapValidationSummary()

                    <div class="col-lg-6">
                        @{
                            AdminPages adminPages = new AdminPages();
                            var selectListBackEndAdminPages = new SelectList(adminPages.GetAllPages(true), "PageId", "PageName", Model.PageParentId);
                        }
                        @Html.BootstrapDropDownListFor(m => m.PageParentId, selectListBackEndAdminPages, MVCwCMS.Resources.Strings.NoParent, autoFocus: true)

                        @Html.BootstrapTextBoxFor(m => m.PageName, labelTooltip: MVCwCMS.Resources.Strings.TooltipAdminPageName)

                        @Html.BootstrapTextBoxFor(m => m.Url, labelTooltip: MVCwCMS.Resources.Strings.TooltipAbsoluteOrRelativeURL)

                        @Html.BootstrapDropDownListFor(m => m.Target, FormHelper.GetSelectListForTarget(FormHelper.SelectedValueForTarget.SameWindow))

                        @Html.BootstrapCheckBoxFor(m => m.ShowInMenu)

                        @Html.BootstrapCheckBoxFor(m => m.IsActive)

                        @Html.BootstrapTextBoxFor(m => m.CssClass)

                        @if (Model.GroupsPermissions.Count > 0)
                        {
                            Groups groups = new Groups();
                            <div class="table-responsive">
                                <table class="table table-condensed table-bordered table-hover table-striped small">
                                    <thead>
                                        <tr>
                                            <th></th>
                                            @foreach (Permission p in Model.GroupsPermissions[0].Permissions)
                                            {
                                                <th class="text-center"><span data-toggle="tooltip" title="@p.PermissionCode">@p.PermissionCode.ToString().Substring(0, 1)</span></th>
                                            }
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @for (int i = 0; i < Model.GroupsPermissions.Count; i++)
                                        {
                                            <tr>
                                                <th>
                                                    @Html.HiddenFor(m => m.GroupsPermissions[i].GroupId)
                                                    @groups.GetGroupById(Model.GroupsPermissions[i].GroupId).GroupName
                                                </th>
                                                @for (int j = 0; j < Model.GroupsPermissions[i].Permissions.Count; j++)
                                                {
                                                    <td class="text-center">
                                                        @Html.HiddenFor(m => m.GroupsPermissions[i].Permissions[j].PermissionCode)
                                                        @Html.CheckBoxFor(m => m.GroupsPermissions[i].Permissions[j].PermissionValue)
                                                    </td>
                                                }
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            </div>
                        }
                    </div>
                </div>
            </div>
        }
    </div>
</div>